package data;

/**
 * ...
 * @author Axel Huizinga axel@cunity.me
 */

class Item 
{
	public var count:Int;
	public var currencySymbol:String;
	public var dataMap:Hash<Xml>;
	public var dataRows(default, null):String;
	public var details(default, null):String;
	public var info(default, null):String;
	public var headline(default, null):String;
	public var id(default, null):String;
	public var price(default, null):Float;
	public var size(default, null):String;
	public var sum(default, null):Float;
	public var title(default, null):String;
	public var packaging(default, null):String;
	public var volume(default, null):Float;
	public var volumeUnit(default, null):String;
	public var vat(default, null):Float;
	
	public function new(xData:Xml) 
	{
		count = 0;
		
		for (a in xData.attributes())		
			if(a ==  'price' || a == 'volume' || a=='vat')
			Reflect.setField(this, a,   Std.parseFloat(xData.get(a)));
		else
			Reflect.setField(this, a, xData.get(a));

		if (xData.elementsNamed('Details').hasNext())
			details = xData.elementsNamed('Details').next().firstChild().nodeValue;			
		if (xData.elementsNamed('Info').hasNext())
			info = xData.elementsNamed('Info').next().firstChild().nodeValue;			
		//trace('info:' + info);
	}
	
}